package pagos;

import java.io.Serializable;
import common.datetime.SimpleDate;
import common.money.MonetaryAmount;

public class CuotaPago implements Serializable{


	private static final long serialVersionUID = -6310963906792344930L;

	private MonetaryAmount amount;

	private String codigoResidente;

	private SimpleDate date;
	
	public CuotaPago(MonetaryAmount amount, String codigoResidente, SimpleDate date) {
		this.amount = amount;
		this.codigoResidente = codigoResidente;
		this.date = date;
	}

	public static CuotaPago createCuotaPago(String amount, String codigoResidente) {
		return new CuotaPago(MonetaryAmount.valueOf(amount), codigoResidente, SimpleDate.today());
	}

	public static CuotaPago createCuotaPago(String amount, String codigoResidente, int month,
			int day, int year) {
		return new CuotaPago(MonetaryAmount.valueOf(amount), codigoResidente, new SimpleDate(month, day,
				year));
	}

	public MonetaryAmount getAmount() {
		return amount;
	}

	public String getcodigoResidente() {
		return codigoResidente;
	}

	public SimpleDate getDate() {
		return date;
	}

	public boolean equals(Object o) {
		if (!(o instanceof CuotaPago)) {
			return false;
		}
		CuotaPago other = (CuotaPago) o;
		// value objects are equal if their attributes are equal
		return amount.equals(other.amount) && codigoResidente.equals(other.codigoResidente)
				&& date.equals(other.date);
	}

	public int hashCode() {
		return amount.hashCode() + codigoResidente.hashCode()  + date.hashCode();
	}

	public String toString() {
		return "Cuota Pago of " + amount + " charged to '" + codigoResidente +  "' on " + date;
	}
	
}
